//
//  FicowStepper.h
//  FicowStepper
//
//  Created by ficow on 16/3/17.
//  Copyright © 2016年 ficow. All rights reserved.
//

#ifndef RGB

#define RGB(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

#endif

#import <UIKit/UIKit.h>

/**
 *  @brief 风格类型
 */
typedef NS_ENUM(NSUInteger,FicowStepperStyle) {
    /**
     *  风格1
     */
    FicowStepperStyleDefault1 = 0,
    /**
     *  风格2
     */
    FicowStepperStyleDefault2 = 1,
    /**
     *  风格3
     */
    FicowStepperStyleDefault3 = 2,
};

@class FicowStepper;
// called when value is changed
typedef void (^FicowStepperValueChangedCallback)(FicowStepper *stepper, float newValue);

// called when value is incremented
typedef void (^FicowStepperIncrementedCallback)(FicowStepper *stepper, float newValue);


// called when value is decremented
typedef void (^FicowStepperDecrementedCallback)(FicowStepper *stepper, float newValue);

@class FicowStepper;

IB_DESIGNABLE
@interface FicowStepper : UIControl

@property (nonatomic, strong) UITextField *countField;
@property (nonatomic, strong) UIColor     *FieldColor;
@property (nonatomic, strong) UIButton    *incrementButton;
@property (nonatomic, strong) UIButton    *decrementButton;

@property (nonatomic) int             value;// default: 0
@property (nonatomic) int             stepInterval;// default: 1
@property (nonatomic) int             minimum;// default: 0
@property (nonatomic) int             maximum;// default: 100
@property (nonatomic) BOOL              hidesDecrementWhenMinimum;// default: NO
@property (nonatomic) BOOL              hidesIncrementWhenMaximum;// default: NO
@property (nonatomic) CGFloat           buttonWidth;// default: 44.0f

//!there are 3 default styles
@property (nonatomic) FicowStepperStyle style;

@property (nonatomic, copy) FicowStepperValueChangedCallback valueChangedCallback;
@property (nonatomic, copy) FicowStepperIncrementedCallback  incrementCallback;
@property (nonatomic, copy) FicowStepperDecrementedCallback  decrementCallback;

// call this method after setting value(s) and callback(s)
// This method will call callback
- (void)setup;
- (void)setDefaultStyle:(FicowStepperStyle)style;

// view customization
- (void)setBorderColor:(UIColor *)color;
- (void)setTextFieldBorderColor:(UIColor*)color;
- (void)setBorderWidth:(CGFloat)width;
- (void)setCornerRadius:(CGFloat)radius;

- (void)setFieldTextColor:(UIColor *)color;
- (void)setFieldFont:(UIFont *)font;

- (void)setButtonTextColor:(UIColor *)color forState:(UIControlState)state;
- (void)setButtonFont:(UIFont *)font;
@end
